#include<stdio.h>
#include<string.h>                                                              
#include<unistd.h>
#include<pthread.h>
#include<fcntl.h>

int main(int argc, char* argv[])
{
    int fd = open("./fifo",O_RDWR);
    int fd1 = open("./fifo1",O_RDWR);
    int pid = fork();
    if(pid == 0) 
    {
        char buf[1024];
        while(1)
        {
            int ret = read(0,buf,sizeof(buf));
            if(*buf==' ') return 0;
            write(fd,buf,ret);
        }
    }
    if(pid > 0)
    {
        char buf[1024];
        while(1)
        {
            int ret = read(fd1,buf,sizeof(buf));
            if(*buf==' ') return 0;
            write(1,buf,ret);
        }
    }
    return 0;
}

